package com.jiangli.mapper;

import com.jiangli.annotation.AutoFill;
import com.jiangli.context.BaseContext;
import com.jiangli.entity.MerchantRating;
import com.jiangli.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface MerchantRatingMapper {

    @AutoFill(OperationType.INSERT)
    void insert(MerchantRating merchantRating);

    @Select("select * from merchant_rating where user_id=#{userId} and merchant_id=#{merchantId}")
    MerchantRating getRating(MerchantRating merchantRating);

    @AutoFill(OperationType.INSERT)
    @Update("update merchant_rating set rating=#{rating} where user_id=#{userId} and merchant_id=#{merchantId}")
    void updateRating(MerchantRating merchantRating);

    @Select("select merchant_id ,user_id,rating from merchant_rating")
    List<MerchantRating> getAllRating();
}
